package handler

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"yzy6.26exam/api/request"
	"yzy6.26exam/internal/bao"
	"yzy6.26exam/internal/moble"
)

func CommitPush(context *gin.Context) {
	var commit_push request.CommitPush
	if err := context.ShouldBind(&commit_push); err != nil {
		context.JSON(http.StatusBadRequest, gin.H{
			"code":    204,
			"message": "解析失败",
			"data":    err.Error(),
		})
		return
	}
	var commit moble.Commit
	commit.VideoId = int32(commit_push.VideoId)
	commit.UserId = int32(commit_push.UserId)
	commit.Data = commit_push.Desc
	err := bao.Create(&commit)
	if err != nil {
		context.JSON(http.StatusOK, gin.H{
			"code":    203,
			"message": "评论失败",
			"data":    err.Error(),
		})
		return
	}
	context.JSON(http.StatusOK, gin.H{
		"code":    203,
		"message": "评论成功",
		//"data":    err.Error(),
	})
	return
}
